package org.gpp.proj1.test;

import java.io.FileNotFoundException;

import org.gpp.proj1.map.MalformedMapFileException;
import org.gpp.proj1.map.editor.EditorFrame;
import org.gpp.proj1.map.editor.InvalidFileException;

import com.jme.util.LoggingSystem;

import easyaccept.EasyAccept;

public class MapEditorFacade extends MapFileParserFacade {

	private EditorFrame editor;
	
	public MapEditorFacade() {
		// Disabling logging
		LoggingSystem.getLoggingSystem().loggerOn( false );
	}

	public void loadEditor() {
		this.editor = new EditorFrame();
		this.editor.setVisible(true);
	}

	public void newMap(int width, int length, int height, int topTextureIndex, int sideTextureIndex, byte modifier) {
		this.editor.simulateNewMapEvent(width, length, height, topTextureIndex, sideTextureIndex, modifier);
	}

	public void saveCurrentMap(String mapFile) throws InvalidFileException, FileNotFoundException {
		this.editor.simulateSaveMapEvent(mapFile);
	}

	public void changeHeight(int l, int c, int height) {
		this.editor.simulateChangeHeightEvent(l, c, height);
	}

	public void setInaccessible(int l, int c) {
		this.editor.simulateChangeAccessibilityEvent(l, c, false);
	}

	public void setAccessible(int l, int c) {
		this.editor.simulateChangeAccessibilityEvent(l, c, true);
	}

	public void changeTexture(int l, int c, String topSide, int value) {
		this.editor.simulateChangeTextureEvent(l, c, topSide.equals("top") ? true : false, value);
	}

	public void applyDecoration(int l, int c, int decoration, int rotation) {
		this.editor.simulateApplyDecorationEvent(l, c, decoration, rotation);
	}

	public void openMapFile(String mapFile) throws InvalidFileException, MalformedMapFileException {
		this.editor.simulateOpenFileEvent(mapFile);
	}

	public static void main(String[] args) {
		args = new String[]{"org.gpp.proj1.test.MapEditorFacade", "test/map_editor_test.txt"};
		EasyAccept.main(args);
	}
}